package com.maigu.dto;


import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.maigu.dataobject.OrderDetail;
import com.maigu.enums.OrderStatusEnum;
import com.maigu.enums.PayStatusEnum;
import com.maigu.utils.EnumUtil;
import com.maigu.utils.serializer.Date2Long;
import lombok.Data;
import net.minidev.json.annotate.JsonIgnore;

import javax.persistence.Id;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
//@JsonInclude(JsonInclude.Include.NON_NULL)//如果json返回值为空则不显示对象
public class OrderDTO {

    private String orderId;
    private String buyerName;
    private String buyerPhone;
    private String buyerAddress;
    private String buyerOpenid;
    private BigDecimal orderAmount;
    private Integer orderStatus;
    private Integer payStatus;
    //使用这个类转换时间
    @JsonSerialize(using= Date2Long.class)
    private Date createTime;
    //使用这个类转换时间
    @JsonSerialize(using= Date2Long.class)
    private Date updateTime;
//    List<OrderDetail> orderDetailList=new ArrayList<>();
    List<OrderDetail> orderDetailList;

    @JsonIgnore
    //这个注解的作用是忽略对象返回值
    public OrderStatusEnum getOrderStatusEnum()
    {
        return EnumUtil.getByCode(orderStatus,OrderStatusEnum.class);
    }

    //这个注解的作用是忽略对象返回值
    @JsonIgnore
    public PayStatusEnum getPayStatusEnum()
    {
        return EnumUtil.getByCode(payStatus,PayStatusEnum.class);
    }
}
